// -*- C++ -*-
-// $Id: babeldata.h,v 1.3 2009/08/03 05:16:23 robertl Exp $
+// $Id: babeldata.h,v 1.4 2010/02/14 05:33:36 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
previewGmap(false),
upgradeCheckMethod(0),
upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))),
- installationUuid(QUuid::createUuid().toString())
+ installationUuid(QUuid::createUuid().toString()),
+ checkUpgradeOnStart(true)
{
};
QDateTime upgradeCheckTime;
QString installationUuid;
+ // Global preferences.
+ bool checkUpgradeOnStart;
+
};
#endif
// -*- C++ -*-
-// $Id: format.cpp,v 1.3 2010/01/17 01:42:10 robertl Exp $
+// $Id: format.cpp,v 1.4 2010/02/14 05:33:37 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
{
saveOptions(settings, name+".input", inputOptions);
saveOptions(settings, name+".output", outputOptions);
- // TODO: Finish this; let's not corrupt the .plsts until we can start from zero.
- if (getReadUseCount() || getWriteUseCount()) {
- settings.setValue(name + ".readcount", getReadUseCount());
- settings.setValue(name + ".writecount", getWriteUseCount());
- }
+ settings.setValue(name + ".readcount", getReadUseCount());
+ settings.setValue(name + ".writecount", getWriteUseCount());
+ settings.setValue(name+".hidden", isHidden());
}
void Format::restoreSettings(QSettings &settings)
{
- restoreOptions(settings, name+".input", inputOptions);
- restoreOptions(settings, name+".output", outputOptions);
+ restoreOptions(settings, name + ".input", inputOptions);
+ restoreOptions(settings, name + ".output", outputOptions);
bumpReadUseCount(settings.value(name + ".readcount").toInt());
bumpWriteUseCount(settings.value(name + ".writecount").toInt());
+ hidden_ = settings.value(name + ".hidden", false).toBool();
}
void Format::setToDefault()
outputOptions[i].setSelected(false);
outputOptions[i].setValue(QVariant());
}
-}
\ No newline at end of file
+}
// -*- C++ -*-
-// $Id: format.h,v 1.4 2010/01/17 21:57:00 robertl Exp $
+// $Id: format.h,v 1.5 2010/02/14 05:33:37 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
writeRoutes(false),
fileFormat(false),
deviceFormat(false),
+ hidden_(false),
extensions(QStringList()),
- html(QString()),
- readUseCount_(0),
- writeUseCount_(0)
+ html(QString()),
+ readUseCount_(0),
+ writeUseCount_(0)
{
inputOptions.clear();
outputOptions.clear();
readWaypoints(readWaypoints), readTracks(readTracks), readRoutes(readRoutes),
writeWaypoints(writeWaypoints), writeTracks(writeTracks), writeRoutes(writeRoutes),
fileFormat(fileFormat), deviceFormat(deviceFormat),
+ hidden_(false),
extensions(extensions),
inputOptions(inputOptions),
outputOptions(outputptions),
readWaypoints(c.readWaypoints), readTracks(c.readTracks), readRoutes(c.readRoutes),
writeWaypoints(c.writeWaypoints), writeTracks(c.writeTracks), writeRoutes(c.writeRoutes),
fileFormat(c.fileFormat), deviceFormat(c.deviceFormat),
+ hidden_(false),
extensions(c.extensions),
inputOptions(c.inputOptions),
outputOptions(c.outputOptions),
html(c.html),
readUseCount_(0),
writeUseCount_(0)
-
{
}
bool isDeviceFormat() const { return deviceFormat; };
bool isFileFormat() const { return fileFormat; };
+ bool isHidden() const { return hidden_; };
void saveSettings(QSettings &settings);
void restoreSettings(QSettings &settings);
void bumpWriteUseCount(int v) { writeUseCount_ += v; }
int getReadUseCount() const { return readUseCount_; }
int getWriteUseCount() const { return writeUseCount_; }
- void zeroUseCounts(void);
+ void zeroUseCounts(void) {
+ readUseCount_ = 0;
+ writeUseCount_= 0;
+ }
private:
QString name, description;
bool readWaypoints, readTracks, readRoutes;
bool writeWaypoints, writeTracks, writeRoutes;
- bool fileFormat, deviceFormat;
+ bool fileFormat, deviceFormat, hidden_;
QStringList extensions;
QList<FormatOption>inputOptions;
QList<FormatOption>outputOptions;
// -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.13 2010/01/17 01:42:10 robertl Exp $
+// $Id: mainwindow.cpp,v 1.14 2010/02/14 05:33:37 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
return (str.length()) ? str.mid(1) : str;
}
+
//------------------------------------------------------------------------
MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
{
//--- Restore from registry
restoreSettings();
- upgrade = new UpgradeCheck();
- upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod,
- bd.upgradeCheckTime, bd.installationUuid,
- formatList);
+
+ if (bd.checkUpgradeOnStart) {
+ upgrade = new UpgradeCheck(parent, formatList);
+ upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod,
+ bd.upgradeCheckTime, bd.installationUuid);
+ }
}
//------------------------------------------------------------------------
ui.inputFormatCombo->clear();
for (int i=0; i<indices.size(); i++) {
int k = indices[i];
- ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
+fprintf(stderr, "%s/%d\n", qPrintable(formatList[k].getName()), formatList[k].isHidden());
+ if (!formatList[k].isHidden())
+ ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
}
setComboToFormat(ui.inputFormatCombo, fmt, true);
fmtChgInterlock = false;
ui.inputFormatCombo->clear();
for (int i=0; i<indices.size(); i++) {
int k = indices[i];
- ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
+fprintf(stderr, "%s/%d\n", qPrintable(formatList[k].getName()), formatList[k].isHidden());
+ if (!formatList[k].isHidden())
+ ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
}
setComboToFormat(ui.inputFormatCombo, fmt, false);
fmtChgInterlock = false;
}
}
- printf("\n");
-
// Release the io_service_t now that we are done with it.
// (void) IOObjectRelease(modemService);
// -*- C++ -*-
-// $Id: upgrade.cpp,v 1.19 2010/01/17 21:57:00 robertl Exp $
+// $Id: upgrade.cpp,v 1.20 2010/02/14 05:33:37 robertl Exp $
/*
Copyright (C) 2009, 2010 Robert Lipe, robertlipe@gpsbabel.org
#include <QSysInfo>
#include <QUrl>
-// static const bool testing = true;
+#if 0
+static const bool testing = true;
+#else
static const bool testing = false;
+#endif
-UpgradeCheck::UpgradeCheck(QWidget *parent) :
+UpgradeCheck::UpgradeCheck(QWidget *parent, QList<Format> &formatList) :
QObject(parent),
- http(0)
+ http(0), formatList_(formatList), updateStatus_(updateUnknown)
{
}
UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tVersionIn,
int checkMethod,
const QDateTime &lastCheckTime,
- const QString &installationUuid,
- QList<Format> &formatList)
+ const QString &installationUuid)
{
- this->currentVersion = currentVersionIn;
- this->currentVersion.remove("GPSBabel Version ");
- this->upgradeCheckMethod = checkMethod;
- this->formatList = &formatList;
+ currentVersion = currentVersionIn;
+ currentVersion.remove("GPSBabel Version ");
+ upgradeCheckMethod = checkMethod;
+// formatList_ = &formatList;
QDateTime soonestCheckTime = lastCheckTime.addDays(1);
if (!testing && QDateTime::currentDateTime() < soonestCheckTime) {
args += "&os_ver=" + getOsVersion();
args += "&beta_ok=1"; // Eventually to come from prefs.
args += "&lang=" + QLocale::languageToString(locale.language());
+ args += "&last_checkin=" + lastCheckTime.toString(Qt::ISODate);
int j = 0;
- for (int i = 0; i < formatList.size(); i++) {
- int rc = formatList[i].getReadUseCount();
- int wc = formatList[i].getWriteUseCount();
- QString formatName = formatList[i].getName();
+
+ for (int i = 0; i < formatList_.size(); i++) {
+ int rc = formatList_[i].getReadUseCount();
+ int wc = formatList_[i].getWriteUseCount();
+ QString formatName = formatList_[i].getName();
if (rc)
args += QString("&uc%1=rd/%2/%3").arg(j++).arg(formatName).arg(rc);
if (wc)
}
if (j)
args += QString("&uc=%1").arg(j);
-
+
+ if (false && testing)
+ fprintf(stderr, "Posting %s\n", qPrintable(args));
+
http->setHost(host, 80);
httpRequestId = http->request(header, args.toUtf8());
QDomNodeList upgrades = document.elementsByTagName("update");
QUrl downloadUrl;
+ updateStatus_ = updateCurrent; // Current until proven guilty.
+
for (unsigned int i = 0; i < upgrades.length(); i++) {
QDomNode upgradeNode = upgrades.item(i);
QDomElement upgrade = upgradeNode.toElement();
upgradeText = upgrade.firstChildElement("overview").text();
// String compare, not a numeric one. Server will return "best first".
if((updateVersion > currentVersion) && updateCandidate) {
+ updateStatus_ = updateNeeded;
response = tr("A new version of GPSBabel is available.<br />"
"Your version is %1 <br />"
"The latest version is %2")
}
upgradeWarningTime = QDateTime(QDateTime::currentDateTime());
+
+ for (int i = 0; i < formatList_.size(); i++) {
+ formatList_[i].zeroUseCounts();
+ }
}
class UpgradeCheck : public QObject {
Q_OBJECT
public:
- UpgradeCheck(QWidget *parent = 0);
+ //UpgradeCheck(QWidget *parent = 0);
+ UpgradeCheck(QWidget *parent, QList<Format> &formatList);
~UpgradeCheck();
typedef enum {
UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion,
int upgradeCheckMethod,
const QDateTime &lastCheckTime,
- const QString &installationUuid,
- QList<Format> &formatList
-
+ const QString &installationUuid
);
QDateTime getUpgradeWarningTime() {
return upgradeWarningTime;
}
+
+ updateStatus getStatus() {
+ return updateStatus_;
+ }
static bool isTestMode(void);
protected:
QDateTime upgradeWarningTime; // invalid time if this object never issued.
QString getOsName(void);
QString getOsVersion(void);
- QList<Format> *formatList;
+ QList<Format> &formatList_;
+ updateStatus updateStatus_;
private slots:
void httpRequestFinished(int requestId, bool error);